/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.        */
/*                                                                 */
/*  NAME      = t__task_mng_list_node_free.c                                */
/*  NOTE      =                                                    */
/*  DATE      = 2014/12/18 by geyh                                 */
/*******************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <CUnit/Basic.h>
#include <CUnit/CUnit.h>

#include "frcomm.h"
#include "frlog.h"
#include "frmem.h"
#include "frlist.h"
#include "conntrack.h"
#include "frame.h"
#include "frtask_mng.h"
#include "apmtest_cunit.h"

static int __suite_init(void)
{
	return 0;
}

static int __suite_cleanup(void)
{
	return 0;
}

void __task_mng_list_node_free(Frlist_node *p_st_node);

static void case1(void)
{
    Frlist_node *p_st_node = NULL;

    __task_mng_list_node_free(p_st_node);

    return;

}

static void case2(void)
{
    Frlist_node *p_st_node = NULL;
    Conntrack *p_st_ct = NULL;

    p_st_ct = (Conntrack *)frmalloc(sizeof(Conntrack));
    p_st_ct->refcnt = 2;

    p_st_node = frlist_node_create(p_st_ct);

    __task_mng_list_node_free(p_st_node);

    CU_ASSERT_EQUAL(((Conntrack *)p_st_node->data)->refcnt ,1);

    frfree(p_st_ct);
    frfree(p_st_node);

    return;

}

int add_suite()
{
	CU_pSuite pSuite = NULL;

	pSuite = CU_add_suite("t__task_mng_list_node_free 测试", __suite_init, __suite_cleanup);

	if (NULL == pSuite)
	{
		return 1;
	}


    //增加测试用例
   	CU_add_test(pSuite, "case1", case1);
   	CU_add_test(pSuite, "case2", case2);

    return 0;

}

int main(int argc, char **argv)
{
    fr_slab_init(52428800, "test");
    run_cunit(add_suite);
    fr_slab_destroy();

    return 0;
}